// pages/f_my/index.js
var app = getApp();
var CommonUtils = app.CommonUtils;
var Urls = require('../../assets/data/f_urls');
const Toptips = require('../../dist/toptips/index');


Page(Object.assign({}, Toptips,{
  /**
   * 页面的初始数据
   */
	data: {
		personInfo: {
			U_ID: '',
			U_Nickname: '',
			U_Headimgurl: '',
			U_Evaluation: '',
			U_Tel: '',
      Token:'',
		},
		contentList: {
			data: [
				{
					"id": 1,
          "icon": "http://172.18.1.155:8058/Image/Ico/我的界面/wodetiwen@2x.png",
					"text": "我的提问",
					"jumpFlag": "/pages/fl_my_answer/index",
				},
				{
					"id": 2,
          "icon": "http://172.18.1.155:8058/Image/Ico/我的界面/wodehuida@2x.png",
					"text": "我的回答",
					"jumpFlag": "/pages/fl_my_huida/index",
				},
				{
					"id": 3,
          "icon": "http://172.18.1.155:8058/Image/Ico/我的界面/wodejifen@2x.png",
					"text": "我的积分",
					"jumpFlag": "/pages/integrate/index",
				},
				{
					"id": 4,
          "icon": "http://172.18.1.155:8058/Image/Ico/我的界面/kefuzhongxin@2x.png",
					"text": "客服中心",
          "jumpFlag": "/pages/f_customer_service/index",
				},
			]
		}
	},

  /**
   * 生命周期函数--监听页面加载
   */
	onLoad: function (options) {

		
	},

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
	onReady: function () {

	},

  /**
   * 生命周期函数--监听页面显示
   */
	onShow: function () {
    var _this = this;
    // CommonUtils.showLoading('加载中...', true)


    try {
      var value = wx.getStorageSync('Token')
      if (value) {
        _this.setData({
          Token: value,

        })
        console.log("111111");
        console.log(_this.data.Token);
        console.log("222222");

        console.log(_this.data.Token);
        wx.request({
          url: Urls.data.url_my_index_user_detail,
          data: {
            DataType: "IndexUserDetail",
            Token: _this.data.Token,
          },

          success: function (res) {
            console.log("1231231");
            console.log(res);
            if (res.data.isok == 'false') {
              _this.showZanTopTips(res.data.info);
              return;
            }
            _this.setData({ personInfo: res.data.data })

          },
          fail: function (res) { _this.showZanTopTips("请稍后尝试"); },
          complete: function (res) { wx.hideLoading() }
        })
      } else {
        _this.setData({
          Token: "0",
        })
      }
    } catch (e) {
      // Do something when catch error
    }
    console.log(_this.data.Token);
	},

  /**
   * 生命周期函数--监听页面隐藏
   */
	onHide: function () {

	},

  /**
   * 生命周期函数--监听页面卸载
   */
	onUnload: function () {

	},

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
	onPullDownRefresh: function () {

	},

  /**
   * 页面上拉触底事件的处理函数
   */
	onReachBottom: function () {

	},

  /**
   * 用户点击右上角分享
   */
	onShareAppMessage: function () {

	},


	/**
	 * 个人中心点击事件
	 */
	btnEventPersonInfo: function (e) {
		wx.navigateTo({
			url: "/pages/f_my/index"
		})
	},

	/**
	 * 内容条目点击事件
	 */
	btnEventContent: function (e) {
		var _this = this;


    try {
      var value = wx.getStorageSync('Token')
      if (value) {

        
        // Do something with return value
        wx.navigateTo({
          url: _this.data.contentList.data[e.currentTarget.dataset.index].jumpFlag
        })
      }else{

        wx.navigateTo({
          url: '../f_binding_phone/index?',
        })
      }
    } catch (e) {
      // Do something when catch error
    }



	},

  push: function(e){
    
    try {
      var value = wx.getStorageSync('Token')
      if (value) {
        wx.navigateTo({
          url: "/pages/f_person_info/index?"
        })
      }else{
        wx.navigateTo({
          url: "/pages/f_binding_phone/index?"
        })
      }
    } catch (e) {
      // Do something when catch error
      

      
    }
    
  }
}))